﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Compiler
{
    public class Token
    {
        public static readonly Token Unknown = new Token("", "UNKNOWN", Int32.MaxValue);
        public static readonly Token EOF = new Token("", "EOF", Int32.MaxValue, Symbol.EOF);

        public readonly string Name;
        public readonly string Pattern;
        public readonly int MaxSize;

        public readonly Symbol Terminal;

        public Token(string Pattern, string Name, int MaxSize)
            : this(Pattern, Name, MaxSize, null)
        {
        }

        public Token(string Pattern, string Name, int MaxSize, Symbol Terminal)
        {
            if (MaxSize == Int32.MaxValue)
                this.Pattern = @"\G" + Pattern;
            else
                this.Pattern = Pattern;

            this.Name = Name;
            this.MaxSize = MaxSize;
            this.Terminal = Terminal;
        }

        public override string ToString()
        {
            return Name;
        }
    }
}
